﻿#@head() 
#@header()
<title>转账</title> 
#@aside("financial")
<style>
	.select2-container{width:150px;float:left;height:35px;margin-top:10px;border-radius:0px !important;}
	.select2-container--default .select2-selection--single{height:35px;}
</style>
<div class="content-wrapper"> 
	<section class="content">
		<div class="nav-tabs-custom">
            <ul class="nav nav-tabs">
			  <li class="active"><a href="#(path)/admin/page/financial-transfer">转账</a></li>
            </ul>
            <div class="tab-content">
				  <!--推广参数配置-->
			  <div class="tab-pane active" id="tab_2">
				<div class="box-body">
					<table id="example1" style="width:800px;" class="table table-striped">
						<tbody>
							<tr>
								<th align="right" style="width:100px;">付款方：</th>
								<td>
									<select style="width:150px;height:35px;float:left;margin-top:10px;" id="userId" class="form-control"></select>
								</td>
							</tr>
							<tr>
								<th align="right" style="width:100px;">收款方：</th>
								<td>
									<select id="borrower" class="form-control"></select>
								</td>
							</tr>
							<tr>
								<th align="right" style="width:100px;">金额：</th>
								<td>
									<input type="text" id="amount"  class="form-control"  />
								</td>
							</tr>
							<tr>
								<th align="right" style="width:100px;">转账说明：</th>  
								<td>
									<input type="text" id="summary"  class="form-control"  />
								</td>
							</tr>
						</tbody>
					</table>
				</div>
				<div class="box-footer">
					<button id="submit" type="submit" style="margin-left:10px;" class="btn btn-info ">提交</button>
					
				  </div>
              </div>
            </div>
            <!-- /.tab-content -->
          </div>
		  
	</section>
</div> 
#@footer()
<script>
$(document).ready(function(){
	var src = "";
	var userid = "";
	var mode = "";
	
	$("#userId").select2({ 
		ajax: {
			type:'GET',
			url: "#(path)/user/list?token=#(session.token??)",
			dataType: 'json',
			delay: 1000,
			data: function (params) {
				return {
					mobile: params.term, // search term 请求参数
					page: params.page
				};
			},
			processResults: function (data, params) {
				var itemList = [];
				var arr = data.data.page.list
				for(item in arr){
					var user = arr[item];
					 
					itemList.push({id:user.id, text: user.real_name});
				}
				return {
					results: itemList
				 };
			},
			cache: true
		},
		placeholder:'请输入手机号搜索...',//默认文字提示
		language: "zh-CN",
		tags: false,//允许手动添加
		allowClear: true,//允许清空
		escapeMarkup: function (markup) { return markup; }, // 自定义格式化防止xss注入
		minimumInputLength: 1,//最少输入多少个字符后开始查询
		formatResult: function formatRepo(repo){return repo.text;}, // 函数用来渲染结果
		formatSelection: function formatRepoSelection(repo){return repo.text;} // 函数用于呈现当前的选择
	});
	<!--融资人-->
	var url2 = "#(path)/user/list?token=#(session.token??)&proStatus=1";
	$.getJSON(url2, function(userli2) { 
		 
		$.each(userli2.data.page.list, function(i, item){ 
			console.log(item);
			$("#borrower").append("<option value='"+item.id+"'>"+item.real_name+"</option>");   
			$("#plusBorrower").append("<option value='"+item.id+"'>"+item.real_name+"</option>");         			
		});
	});
	$("#submit").click(function() {
		var amount = $("#amount").val();
		var borrower = $("#borrower").val();
		var userid = $("#userId").val();
		var summary = $("#summary").val();
		var url = "#(path)/transfer?token=#(session.token??)&from="+userid+"&to="+borrower+"&amount="+amount+"&summary="+summary;
		layer.confirm('是否确认提交？', {btn : [ '确认', '取消' ]}, function() {
			layer.msg('发放中，请稍等...',function(){
				ajax(url,{},function(data){
					if(data.code=='success'){
						layer.msg(data.msg, {icon:1},function(){
						});
					}else if(data.code=='error'){
						layer.msg(data.msg, {icon : 2});
					}
				});
			});
		}, function() {
			layer.msg('已取消！', {icon : 1});
		});
	});
	
});
</script>
</body>
</html>

